#include <iostream>
#include <string>
#include <cstring>
using namespace std;
#include "../NSocket.h"

using namespace std;
int main()
{
    char     szBuffer[1024];
    int      iByteRecv = 0;
    CNSocket Sock;
    CNSocket SockSend;
	Sock.NewSocket();
	Sock.Bind("127.0.0.1",8080);
	Sock.Listen();
	printf("Accept...\n");
	SockSend = Sock.Accept();
	printf("...ok\n");
	Sock.Close();

	while(1)
	{
	     iByteRecv = SockSend.Recv(szBuffer,1024);
	     szBuffer[iByteRecv] = '\0';
	     printf("recv:%s\n",szBuffer);

         printf("entry to send:\n");
         fgets(szBuffer,1024,stdin);
         SockSend.Send(szBuffer,strlen(szBuffer));
         printf("send ok\n");
 }

	return 0;
}
